package com.lcf.app;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.lang.Console;
import org.bytedeco.javacpp.Loader;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Arrays;

public class Main {


    public static void main(String[] args) throws Exception {
        TimeInterval timer = DateUtil.timer();
        /*// 裁剪音频
        FFmpegUtils.audioClip("F:/Ludwig van Beethoven - 致艾丽丝.mp3",
                "F:/Ludwig van Beethoven - 致艾丽丝（新）.mp3",
                10000, 70000, false);
        Console.log("裁剪音频耗时：{}/ms", timer.intervalRestart());
        //裁剪视频
        FFmpegUtils.videoClip("C:/Users/Administrator/Desktop/声像测试数据/企业宣传片.mp4",
                "C:/Users/Administrator/Desktop/声像测试数据/企业宣传片(新).mp4",
                10000, 70000, false);
        Console.log("裁剪视频耗时：{}/ms", timer.intervalRestart());

        BufferedImage bufferedImage = FFmpegUtils.videoCoverImage(Files
                .newInputStream(Paths.get("C:/Users/Administrator/Desktop/声像测试数据/企业宣传片.mp4")));
        if (bufferedImage != null) {
            ImageIO.write(bufferedImage, "png", new File("F://my.png"));
        }
        Console.log("获取视频封面耗时：{}/ms", timer.intervalRestart());*/


        String input = "C:/Users/Administrator/Desktop/声像测试数据/企业宣传片.mp4";
        String output = "C:/Users/Administrator/Desktop/声像测试数据/企业宣传片1.mp4";
        //FFmpegUtils.cutVideo(input, output, "00:00:10", 30);
        //boolean b = FFmpegUtils.cutVideo(input, output, "00:00:10", "00:00:25");

        //FFmpegUtils.help();

        /*FFmpegUtils.cutAudio("F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝.mp3",
                "F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝1.mp3",
                "00:00:05", 20);*/

        /*FFmpegUtils.cutAudio("F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝.mp3",
                "F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝1.mp3",
                "00:00:05", "00:00:20");*/

        /*FFmpegUtils.cut("http://192.168.0.210:9000/ljd-archive-minio/image/2023/06/08/1b3022273de04f2aa7ee6552ddc9aa88.mp4",
                "F:/555.mp4", "00:00:10", 60);*/

        /*
        FFmpegUtils.convert("F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字.mkv",
                "F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字.mp4");
           */

        /*FFmpegUtils.getVideoImg("F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字.mkv",
                "F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字.jpg", 10);

        /*FFmpegUtils.removeFrom("F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字.mkv",
                "F:\\迅雷下载\\阳光电影dy.ygdy8.com.疾速追杀4.2023.HD.1080P.中英双字1.mkv", "20", "30");*/


        /*FFmpegUtils.merge(Arrays.asList("F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝.mp3",
                "F:\\CloudMusic\\beFour - How Do You Do ？.mp3"), "F:/aaaaaaaaaaaa.mp3");*/

        /*int duration = FFmpegUtils.duration("F:\\CloudMusic\\Ludwig van Beethoven - 致艾丽丝.mp3");
        System.out.println(LocalTime.ofSecondOfDay(duration));*/

/*        boolean b = FFmpegUtils.removeFrom("F:\\CloudMusic\\1983 - 对不起 我爱你.mp3",
                "F:\\CloudMusic\\1983 - 对不起 我爱你1.mp3",
                "00:00:00", "00:05:40");
        Console.log(b);*/

        /*FFmpegUtils.convert("C:\\Users\\Administrator\\Documents\\WeChat Files\\wxid_bij0qf56w0ib21\\FileStorage\\File\\2023-08\\0c10982d96771ec38f3e6b3cbf5fe89a_raw-0001.MPG",
                "F:/to-mp4.mp4");*/

        /*String toMp4 = FFmpegUtils.convertToMp4(new File("C:\\Users\\Administrator\\Documents\\WeChat Files\\wxid_bij0qf56w0ib21\\FileStorage\\File\\2023-08\\0c10982d96771ec38f3e6b3cbf5fe89a_raw-0001.MPG"));
        System.out.println(toMp4);*/

        // FFmpegUtils.command("-codecs");

        //FFmpegUtils.videoToMp4("F:\\2019年阳江游学之旅视频\\阳江游学之旅.MPG", "F:\\2019年阳江游学之旅视频\\阳江游学之旅_.mp4");

        FFmpegUtils.audioToMp3("http://192.168.0.210:9000/ljd-archive-minio/video/2023/08/18/409af112666044f792320d7e0e4ca5ad.flv", "F:/aaaaa.mp4");

        Console.log("耗时：{}/秒", timer.intervalSecond());

    }

}